package com.minjiang.system.service.sec.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.minjiang.model.system.MyDynamic;
import com.minjiang.model.system.MyUser;
import com.minjiang.model.system.SysLoginLog;
import com.minjiang.model.vo.MyDynamicQueryVo;
import com.minjiang.model.vo.MyDynamicVo;
import com.minjiang.system.mapper.sec.MyUserMapper;
import com.minjiang.system.service.sec.MyDynamicService;
import com.minjiang.system.mapper.sec.MyDynamicMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
* @author Administrator
* @description 针对表【my_dynamic(动态数据)】的数据库操作Service实现
* @createDate 2022-12-18 16:20:32
*/
@Service
public class MyDynamicServiceImpl extends ServiceImpl<MyDynamicMapper, MyDynamic>
    implements MyDynamicService{

    @Autowired
    private MyDynamicMapper myDynamicMapper;
    @Autowired
    private MyUserMapper myUserMapper;

    /**
     * 获取动态分页数据
     * @param pageParam
     * @param dynamicQueryVo
     * @return
     */
    @Override
    public IPage<MyDynamic> selectPage(Page<MyDynamic> pageParam, MyDynamicQueryVo dynamicQueryVo) {
        //获取条件值
        String keyword = dynamicQueryVo.getKeyword();
        String createTimeBegin = dynamicQueryVo.getCreateTimeBegin();
        String createTimeEnd = dynamicQueryVo.getCreateTimeEnd();
        //封装条件
        QueryWrapper<MyDynamic> wrapper = new QueryWrapper<>();
        if(!StringUtils.isEmpty(keyword)) {
            wrapper.like("text",keyword);
        }
        if(!StringUtils.isEmpty(createTimeBegin)) {
            wrapper.ge("create_time",createTimeBegin);
        }
        if(!StringUtils.isEmpty(createTimeBegin)) {
            wrapper.le("create_time",createTimeEnd);
        }
        //调用mapper方法
        IPage<MyDynamic> pageModel = myDynamicMapper.selectPage(pageParam, wrapper);


        return pageModel;
    }
}




